package com.le.tester.book.effectivejava3rdchinese.secondReading.l25;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

/**
 * createTime：2024-09-04 15:50
 * description：不安全转换
 */
public class Unsafe {
    public static void main(String[] args) {
        List<String> strings = new ArrayList<>();
        unsafeAdd(strings, Integer.valueOf(42));
        String s = strings.get(0);

    }

    private static void unsafeAdd(List list, Object o) {
        list.add(o);
    }

    static int numElementsInCommon(Set s1, Set s2) {
        int result = 0;
        for (Object o1 : s1)
            if (s2.contains(o1))
                result++;
        return result;
    }

}
